{% extends "base.html" %}
{% block title %} 商品详情{% endblock %}
{% block header %}
{% endblock %}
{% block content %}


<div class="container">
  <div class="span12">
    <div class="alert alert-info">
      <a class="close" data-dismiss="alert">×</a>
      <h5>Tips, remove me!</h5>
      <ul>
        <li>如果商品已被人购买了，不显示“购买”按钮。</li>
        <li>请注意买家信息的保护，只有卖家能看到。</li>
      </ul>
    </div>
  </div>
</div>

<div class="container">
  {% if session.is_login and goods.own_user==session.user_id and goods.flags%}
  <div class="span12">
    <div class="alert alert-success">
      <h4>买家信息：</h4>
      <p>
        购买时间：{{goods.buy_time}}<br />
        帐号：{{buy_user.username}} <br />
        姓名：{{buy_user.truename}} <br />
        电话：{{buy_user.phone}} <br />
        邮编：{{buy_user.zipcode}} <br />
        地址：{{buy_user.address}}
      </p>
    </div>
  </div>
  {% endif %}
  <div class="span12">
    <table class="table table-bordered table-striped">
      <tbody>
        <tr>
          <td>名称</td>
          <td>
            <h2>{{goods.name}}</h2>
          </td>
        </tr>
        <tr>
          <td>标签</td>
          <td>
            {% for tag in goods.tags %}
            <span class="label">{{tag}}</span>
            {% endfor %}
          </td>
        </tr>
        <tr>
          <td>价格</td>
          <td>
            <h4>{{goods.price}}元</h4>
          </td>
        </tr>
        <tr>
          <td>主人</td>
          <td>{{own_user.username}}</td>
        </tr>
        <tr>
          <td>创建时间</td>
          <td>{{goods.create_time}}</td>
        </tr>
        <tr>
          <td>详细描述</td>
          <td>{{goods.description}}</td>
        </tr>
        <tr>
          <td></td>
          <td>
            {% if not goods.flags and session.user_id!=own_user.id %}
            <a href="\buy_goods\?gid={{goods.id}}"><button class="btn btn-danger">购买</button></a>
            {% endif %}
            <button class="btn" onClick="javascript :history.back(-1);">返回</button>
          </td>
        </tr>
        <tr>
          <td colspan="2"><img src="{{goods.img}}" alt="" /></td>
        </tr>
      </tbody>
    </table>
  </div>
</div>
{% endblock %}